import { createApp } from "vue";
import { store } from "./store";
import 'vant/es/image-preview/style'
// normalize.css
import "normalize.css/normalize.css";
import selectView from "@/utils/install"
import {showImagePreview,showFailToast} from "vant";
import 'vant/lib/index.css';

// 全局样式
import "./styles/index.less";
// import 'default-passive-events'
// tailwindcss
import "./styles/tailwind.css";
// svg icon
import "virtual:svg-icons-register";

import App from "./App.vue";
import router from "./router";
// import globalPlugin from './plugins/global';
declare module '@vue/runtime-core' {
    interface ComponentCustomProperties {
        $token: (a:string) => Promise<void>
        $imgSrc: (a:string) => Promise<void>
        $is_vip: (a:string) => Promise<void>
        $name: (a:string) => Promise<void>
        $sayToken: () => void;
        $sayIs_vip: () => void;
        $sayIs_yx: () => void;
        $NIM:()=>void;
        $showImagePreview:()=>void;
        $wy_token:(a:string) => Promise<void>
        $wy_accid:(a:string) => Promise<void>
    }
}
// declare function showImagePreview({})

const app = createApp(App);
app.config.globalProperties.$token = localStorage.getItem("token")
app.config.globalProperties.$NIM = null
app.config.globalProperties.$is_vip = localStorage.getItem("is_vip")
app.config.globalProperties.$wy_token = localStorage.getItem("wy_token")
app.config.globalProperties.$wy_accid = localStorage.getItem("wy_accid")
app.config.globalProperties.$name = localStorage.getItem("name")
app.config.globalProperties.$imgSrc = 'https://csnakegoods.xm888.app/'

app.config.globalProperties.$sayToken = (e) => {
    localStorage.setItem("token",e)
    app.config.globalProperties.$token = e


};
app.config.globalProperties.$sayIs_yx = (e,a,c) => {
    localStorage.setItem("wy_token",e)
    localStorage.setItem("wy_accid",a)
    localStorage.setItem("name",c)
    app.config.globalProperties.$wy_token = e
    app.config.globalProperties.$wy_accid = a
    app.config.globalProperties.$name  = c
};
app.config.globalProperties.$sayIs_vip = (e) => {
    localStorage.setItem("is_vip",e)
    app.config.globalProperties.$is_vip = e
};
app.config.globalProperties.$showImagePreview = (e) => {
    if(!e){
        showFailToast('暂无投注截屏')
        return
    }
    showImagePreview({
        images:[e],
        startPosition:1,
        showIndex:false,
        closeIconPosition:'top-right',
        // closeable: true,
        className:"image_image"
    })
};
// app.config.globalProperties.$token = localStorage.getItem("token")

app.use(store);
app.use(router);
app.use(selectView)
// app.use(Dialog)
// app.use(globalPlugin)

app.mount("#app");
